<?php
/**
 * @package		Joomla.Site for Joomla 2.5
 * @subpackage	mod_articles_subcategories
 * @author      Proweb Solutionz
 * @copyright	Copyright (C)  2012  prowebsolutionz.com. All rights reserved.
 * @license		GNU/GPL v2 or later http://www.gnu.org/licenses/gpl-2.0.html; 
 */

// no direct access
defined('_JEXEC') or die;

require_once JPATH_SITE.'/components/com_content/helpers/route.php';
jimport('joomla.application.categories');

abstract class modArticlesSubCategoriesHelper
{
	public static function getList(&$params)
	{
		$categories = JCategories::getInstance('Content');
		$option		= JRequest::getCmd('option');
		$view		= JRequest::getCmd('view');
		$items = array();
    
    if ($option == 'com_content' && $view == 'category'){
      $catid = JRequest::getVar('id');
      if ($categories->get($catid)->hasChildren()){
        $items = $categories->get($catid)->getChildren();
      }
    }
    return $items;
	}
  public static function getCategory(){
    $option		= JRequest::getCmd('option');
		$view		= JRequest::getCmd('view');
    $category  = '';
    if ($option == 'com_content' && $view == 'category'){
      $catid = JRequest::getVar('id');
      $db =& JFactory::getDBO();
      $query  =  "SELECT title FROM #__categories WHERE id = " . $catid;
      $db->setQuery($query );
      $category = $db->loadResult();
    }
    return $category;
  }
}
